package test;

import java.io.BufferedInputStream;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.OutputStream;
import java.io.PrintWriter;
import java.net.ServerSocket;
import java.net.Socket;

public class Server {

	public static void main(String[] args) throws InterruptedException {
		while (true) {
			try {
				ServerSocket server = new ServerSocket(4700);
				Socket socket = server.accept();
				OutputStream os = socket.getOutputStream();
				InputStream is = socket.getInputStream();
				byte[] b = new byte[14];
				byte[] gb = new byte[14];
				if (is.read(gb) != -1) {
					if (gb[0] == 0x00) {
						os.write(0x00);
						os.flush();
					}
					Thread.sleep(3000);
					System.out.println("Server++:" + b[0]);
					System.out.println("Client++:" + gb[0]);
				}
			} catch (Exception e) {
				continue;
			}
		}
	}
}
